home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.ImageObserver;
-
- class KRCanvas2 extends Canvas implements Runnable {
- Thread theThread;
- int[] currentX;
- int[] currentY;
- int[] direction;
- int increment;
- int delay;
- int numSegments;
- Color theColor;
- Image osImage;
- Graphics osg;
- int red;
- int green;
- int blue;
- int redStep;
- int greenStep;
- int blueStep;
- // $FF: renamed from: i int
- int field_0;
- Color[] colors;
- int blockSpacing = 1;
- boolean showCircles;
- boolean sineCalc;
- int mode;
- int blockWidth;
- int blockHeight;
- static final int MODE_EAST_WEST = 0;
- static final int MODE_SOUTH_NORTH = 1;
- Color bkColor;
- Image bkImage;
-
- public KRCanvas2(Applet var1, int var2) {
- this.GetParameters(var1, var2);
- }
-
- void GetParameters(Applet var1, int var2) {
- String var3 = var1.getParameter("krBlockSpacing" + var2);
- this.blockSpacing = AppletParam2.GetInt(var3, 1);
- var3 = var1.getParameter("krSpeed" + var2);
- this.delay = AppletParam2.GetInt(var3, 100);
- var3 = var1.getParameter("krNumSegments" + var2);
- this.numSegments = AppletParam2.GetInt(var3, 5);
- var3 = var1.getParameter("krColor" + var2);
- this.theColor = AppletParam2.GetColor(var3, Color.red);
- var3 = var1.getParameter("krShowCircles" + var2);
- this.showCircles = AppletParam2.GetBoolean(var3, false);
- var3 = var1.getParameter("krSineCalc" + var2);
- this.sineCalc = AppletParam2.GetBoolean(var3, true);
- var3 = var1.getParameter("krUpDown" + var2);
- if (AppletParam2.GetBoolean(var3, false)) {
- this.mode = 1;
- } else {
- this.mode = 0;
- }
-
- var3 = var1.getParameter("krBlockSize" + var2);
- int var4 = AppletParam2.GetInt(var3, 10);
- if (this.mode == 0) {
- this.blockWidth = var4;
- } else {
- this.blockHeight = var4;
- }
-
- var3 = var1.getParameter("krBkColor" + var2);
- this.bkColor = AppletParam2.GetColor(var3, Color.black);
- ((Component)this).setBackground(this.bkColor);
- var3 = var1.getParameter("krBkImage" + var2);
- this.bkImage = var1.getImage(var1.getCodeBase(), var3);
- }
-
- public void Start() {
- this.theThread = new Thread(this);
- this.theThread.start();
- }
-
- public void Stop() {
- this.theThread.stop();
- this.theThread = null;
- }
-
- public void update(Graphics var1) {
- if (this.osImage == null) {
- this.osImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.osg = this.osImage.getGraphics();
- }
-
- this.osg.setColor(((Component)this).getBackground());
- this.osg.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- if (this.bkImage != null) {
- int var2 = this.bkImage.getWidth(this);
- int var3 = this.bkImage.getHeight(this);
- int var4 = ((Component)this).size().width / var2;
- int var5 = ((Component)this).size().height / var3;
- ++var4;
- ++var5;
-
- for(int var6 = 0; var6 < var5; ++var6) {
- for(int var7 = 0; var7 < var4; ++var7) {
- this.osg.drawImage(this.bkImage, var7 * var2, var6 * var3, this);
- }
- }
- }
-
- for(this.field_0 = 0; this.field_0 < this.numSegments; ++this.field_0) {
- this.osg.setColor(this.colors[this.field_0]);
- if (this.mode == 0) {
- if (!this.showCircles) {
- this.osg.fillRect(this.currentX[this.field_0], this.currentY[this.field_0], this.blockWidth, this.blockHeight);
- } else {
- this.osg.fillOval(this.currentX[this.field_0], this.currentY[this.field_0], this.blockWidth, this.blockHeight);
- }
- } else if (!this.showCircles) {
- this.osg.fillRect(this.currentX[this.field_0], this.currentY[this.field_0], this.blockWidth, this.blockHeight);
- } else {
- this.osg.fillOval(this.currentX[this.field_0], this.currentY[this.field_0], this.blockWidth, this.blockHeight);
- }
- }
-
- this.UpdatePositions();
- var1.drawImage(this.osImage, 0, 0, (ImageObserver)null);
- }
-
- public void run() {
- try {
- while(true) {
- ((Component)this).repaint();
- Thread.sleep((long)this.delay);
- }
- } catch (InterruptedException var1) {
- }
- }
-
- public void UpdatePositions() {
- for(int var1 = 0; var1 < this.numSegments; ++var1) {
- if (this.mode == 0) {
- int[] var10000 = this.currentX;
- var10000[var1] += (this.blockWidth + this.blockSpacing) * this.direction[var1];
- if (this.direction[var1] == 1) {
- if (this.currentX[var1] >= ((Component)this).size().width - this.blockWidth) {
- this.direction[var1] = -1;
- this.currentX[var1] = ((Component)this).size().width - this.blockWidth;
- }
- } else if (this.currentX[var1] <= 0) {
- this.direction[var1] = 1;
- this.currentX[var1] = 0;
- }
- } else {
- int[] var2 = this.currentY;
- var2[var1] += (this.blockHeight + this.blockSpacing) * this.direction[var1];
- if (this.direction[var1] == 1) {
- if (this.currentY[var1] >= ((Component)this).size().height - this.blockHeight) {
- this.direction[var1] = -1;
- this.currentY[var1] = ((Component)this).size().height - this.blockHeight;
- }
- } else if (this.currentY[var1] <= 0) {
- this.direction[var1] = 1;
- this.currentY[var1] = 0;
- }
- }
- }
-
- }
-
- public Dimension minimumSize() {
- return this.mode == 0 ? new Dimension(100, 20) : new Dimension(20, 100);
- }
-
- public Dimension preferredSize() {
- return this.mode == 0 ? new Dimension(100, 20) : new Dimension(20, 100);
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- this.osImage = null;
- this.osg = null;
- if (this.mode == 0) {
- this.blockHeight = var4;
- } else {
- this.blockWidth = var3;
- }
-
- this.currentX = new int[this.numSegments];
- this.currentY = new int[this.numSegments];
- this.direction = new int[this.numSegments];
- if (this.mode == 0) {
- this.increment = var4;
- } else {
- this.increment = var3;
- }
-
- for(int var5 = 0; var5 < this.numSegments; ++var5) {
- if (this.mode == 0) {
- this.currentX[var5] = -((this.numSegments - 1 - var5) * (this.blockWidth + this.blockSpacing));
- this.currentY[var5] = 0;
- } else {
- this.currentX[var5] = 0;
- this.currentY[var5] = -((this.numSegments - 1 - var5) * (this.blockHeight + this.blockSpacing));
- }
-
- this.direction[var5] = 1;
- }
-
- this.red = this.theColor.getRed();
- this.green = this.theColor.getGreen();
- this.blue = this.theColor.getBlue();
- this.redStep = this.red / this.numSegments;
- this.greenStep = this.green / this.numSegments;
- this.blueStep = this.blue / this.numSegments;
- this.colors = new Color[this.numSegments];
- if (!this.sineCalc) {
- for(this.field_0 = 1; this.field_0 <= this.numSegments; ++this.field_0) {
- this.colors[this.field_0 - 1] = new Color(this.redStep * this.field_0, this.greenStep * this.field_0, this.blueStep * this.field_0);
- }
-
- } else {
- double var6 = (Math.PI / 2D) / (double)this.numSegments;
-
- for(this.field_0 = 1; this.field_0 <= this.numSegments; ++this.field_0) {
- double var11 = Math.sin(var6 * (double)this.field_0);
- int var8 = (int)((double)this.red * var11);
- int var9 = (int)((double)this.green * var11);
- int var10 = (int)((double)this.blue * var11);
- this.colors[this.field_0 - 1] = new Color(var8, var9, var10);
- }
-
- }
- }
- }
-